package designPattern.action11.Iterator.A1.concrete;

import java.util.ArrayList;

import designPattern.action11.Iterator.A1.bean.Book;
import designPattern.action11.Iterator.A1.sketch.Aggregate;
import designPattern.action11.Iterator.A1.sketch.Iterator;

public class BookShelf implements Aggregate {
    private ArrayList books;

    public BookShelf(int initialsize) {
        this.books = new ArrayList(initialsize);
    }

    public Book getBookAt(int index) {
        return (Book) books.get(index);
    }

    public void appendBook(Book book) {
        books.add(book);
    }

    public int getLength() {
        return books.size();
    }

    public Iterator iterator() {
        return new BookShelfIterator(this);
    }
}
